home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gxfcmap.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  5.4 KB  |  151 lines

  1. /* Copyright (C) 1997, 2000 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gxfcmap.h,v 1.5 2000/09/19 19:00:36 lpd Exp $ */
  20. /* Internal CMap structure definitions */
  21.  
  22. /* This file should be called gxcmap.h, except that name is already used. */
  23.  
  24. #ifndef gxfcmap_INCLUDED
  25. #  define gxfcmap_INCLUDED
  26.  
  27. #include "gsfcmap.h"
  28. #include "gsuid.h"
  29. #include "gxcid.h"
  30.  
  31. /*
  32.  * A CMap has 3 separate parts, each designed for a different function:
  33.  *
  34.  *    - The code space, used for parsing the input string.
  35.  *
  36.  *    - Two key maps, one for defined characters, one for notdefs.
  37.  *    Each of these maps a parsed character to an index in a value table.
  38.  *
  39.  *    - Two value tables in which each entry specifies a string, a name,
  40.  *    or a CID.
  41.  *
  42.  * We separate the value tables from the key maps so that large, closely
  43.  * related CMaps such as UniCNS-UCS2-H and UniCNS-UTF8-H can (someday)
  44.  * share the value tables but not the code space or key maps.
  45.  */
  46.  
  47. /*
  48.  * A code space is a non-empty array of code space ranges.  The array is
  49.  * sorted lexicographically.  Ranges must not overlap.  In each range,
  50.  * first[i] <= last[i] for 0 <= i < num_bytes.
  51.  */
  52. #define MAX_CMAP_CODE_SIZE 4
  53. typedef struct gx_code_space_range_s {
  54.     byte first[MAX_CMAP_CODE_SIZE];
  55.     byte last[MAX_CMAP_CODE_SIZE];
  56.     int size;            /* 1 .. MAX_CMAP_CODE_SIZE */
  57. } gx_code_space_range_t;
  58. typedef struct gx_code_space_s {
  59.     gx_code_space_range_t *ranges;
  60.     int num_ranges;
  61. } gx_code_space_t;
  62.  
  63. /*
  64.  * A lookup table is a non-empty array of lookup ranges.  Each range has an
  65.  * associated sorted lookup table, indexed by the num_key_bytes low-order
  66.  * code bytes.  If key_is_range is true, each key is a range (2 x key_size
  67.  * bytes); if false, each key is a single code (key_size bytes).
  68.  */
  69. typedef enum {
  70.     CODE_VALUE_CID,        /* CIDs */
  71.     CODE_VALUE_GLYPH,        /* glyphs */
  72.     CODE_VALUE_CHARS        /* character(s) */
  73. #define CODE_VALUE_MAX CODE_VALUE_CHARS
  74. } gx_code_value_type_t;
  75. /* The strings in this structure are all const after initialization. */
  76. typedef struct gx_code_lookup_range_s {
  77.     gs_cmap_t *cmap;        /* back pointer for glyph marking */
  78.     /* Keys */
  79.     byte key_prefix[MAX_CMAP_CODE_SIZE];
  80.     int key_prefix_size;    /* 1 .. MAX_CMAP_CODE_SIZE */
  81.     int key_size;        /* 0 .. MAX_CMAP_CODE_SIZE - key_prefix_s' */
  82.     int num_keys;
  83.     bool key_is_range;
  84.     gs_string keys;        /* [num_keys * key_size * (key_is_range+1)] */
  85.     /* Values */
  86.     gx_code_value_type_t value_type;
  87.     int value_size;        /* bytes per value */
  88.     gs_string values;        /* [num_keys * value_size] */
  89.     int font_index;
  90. } gx_code_lookup_range_t;
  91. /*
  92.  * The GC descriptor for lookup ranges is complex, because it must mark
  93.  * names.
  94.  */
  95. extern_st(st_code_lookup_range_element);
  96. #define public_st_code_lookup_range() /* in gsfcmap.c */\
  97.   gs_public_st_composite(st_code_lookup_range, gx_code_lookup_range_t,\
  98.     "gx_code_lookup_range_t", code_lookup_range_enum_ptrs,\
  99.     code_lookup_range_reloc_ptrs)
  100. #define public_st_code_lookup_range_element() /* in gsfcmap.c */\
  101.   gs_public_st_element(st_code_lookup_range_element, gx_code_lookup_range_t,\
  102.     "gx_code_lookup_range_t[]", code_lookup_range_elt_enum_ptrs,\
  103.     code_lookup_range_elt_reloc_ptrs, st_code_lookup_range)
  104.  
  105. /*
  106.  * The main body of data in a CMap is two code maps, one for defined
  107.  * characters, one for notdefs.
  108.  */
  109. typedef struct gx_code_map_s {
  110.     gx_code_lookup_range_t *lookup;
  111.     int num_lookup;
  112. } gx_code_map_t;
  113.  
  114. /* A CMap proper is relatively simple. */
  115. struct gs_cmap_s {
  116.     int CMapType;        /* must be first; must be 0 or 1 */
  117.     gs_const_string CMapName;
  118.     gs_cid_system_info_t *CIDSystemInfo; /* [num_fonts] */
  119.     int num_fonts;
  120.     float CMapVersion;
  121.     gs_uid uid;            /* XUID or nothing */
  122.     long UIDOffset;
  123.     int WMode;
  124.     gx_code_space_t code_space;
  125.     gx_code_map_t def;        /* defined characters */
  126.     gx_code_map_t notdef;    /* notdef characters */
  127.     gs_glyph_mark_proc_t mark_glyph;    /* glyph marking procedure for GC */
  128.     void *mark_glyph_data;    /* closure data */
  129.     gs_glyph_name_proc_t glyph_name;    /* glyph name procedure for printing */
  130.     void *glyph_name_data;    /* closure data */
  131. };
  132.  
  133. extern_st(st_cmap);
  134. #define public_st_cmap()    /* in gsfcmap.c */\
  135.   BASIC_PTRS(cmap_ptrs) {\
  136.     GC_CONST_STRING_ELT(gs_cmap_t, CMapName),\
  137.     GC_OBJ_ELT3(gs_cmap_t, CIDSystemInfo, uid.xvalues, code_space.ranges),\
  138.     GC_OBJ_ELT2(gs_cmap_t, def.lookup, notdef.lookup),\
  139.     GC_OBJ_ELT2(gs_cmap_t, mark_glyph_data, glyph_name_data)\
  140.   };\
  141.   gs_public_st_basic(st_cmap, gs_cmap_t, "gs_cmap",\
  142.     cmap_ptrs, cmap_data)
  143.  
  144. /*
  145.  * Initialize a just-allocated CMap, to ensure that all pointers are clean
  146.  * for the GC.
  147.  */
  148. void gs_cmap_init(P1(gs_cmap_t *));
  149.  
  150. #endif /* gxfcmap_INCLUDED */
  151.